package com.shallwead.bna.Async;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;

import com.shallwead.bna.object.AdClick;
import com.shallwead.bna.util.JSON;
import com.shallwead.bna.util.Logger;

public class AdClickAsync extends AsyncTask<Void, String, Boolean> {

	Context mContext;
	String Url;
	AdClick adClick;

	public AdClickAsync(Context mContext, String Url, AdClick adClick) {
		this.mContext = mContext;
		this.Url = Url;
		this.adClick = adClick;
	}

	@Override
	protected Boolean doInBackground(Void... params) {
		return JSON.sendAdClick(mContext, adClick);
	}

	@Override
	protected void onPostExecute(Boolean result) {
		super.onPostExecute(result);
		Logger.e(Url);
		mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Url))
				.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
	}
}
